package org.fly;

import redis.clients.jedis.Jedis;

import java.util.Iterator;
import java.util.Set;


public class RedisKeyJava {
    public static void main(String[] args) {
        //连接本地的 Redis 服务
        Jedis jedis = new Jedis("localhost");
        System.out.println("Connection to server sucessfully");

        // 获取数据并输出
        Set<String> set = jedis.keys("*");

        Iterator<String> iterator = set.iterator();
        while (iterator.hasNext()) {
            String str = iterator.next();
            System.out.println("List of stored keys:: " + str);
        }
    }
}